$(function() {
	$('#vue_vm_list div').hide();
	findAll();
});

var subjectRoom = {
	subjectRoomId: '',
	roomName: '',
	function: '',
	telPhone: '',
	departmentId: '',
	buildingId: '',
	floorsId: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
	remark: '',
	departmentName: '',
	buildingName: '',
	floorsName: '',
};

var view = {
	data: subjectRoom
};

var vue_vm = new Vue({
	el: '#vue_vm',
	data: view
});

function save() {
	var floorIds = '';
	var floorNames = '';
	$('.floor-checkbox').each(function() {
		if($(this).find('.magic-checkbox').is(':checked')) {
			var checkbox = $(this).find('.magic-checkbox');
			var floorId = checkbox.attr('id');
			var floorName = checkbox.val();
			floorIds += (floorIds==''? '': ',') + floorId;
			floorNames += (floorNames==''? '': ',') + floorName;
		}
	});
	
	view.data.floorsId = floorIds;
	view.data.floorsName = floorNames;
	
	save_basic(path+'/subjectRoom/save', {subjectRoom:view.data}, function() {
		alert('保存成功');
		findAll();
	});
}

function findAll() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();

	findAll_basic(path+'/subjectRoom/findAll', function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/subjectRoom/deleteBatch');
}
